package inventory.controller;


import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import inventory.common.ResultData;
import inventory.entity.User;
import inventory.mapper.UserMapper;
import inventory.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Api(tags="账户信息控制类")
@RestController
public class TestController {

    @Resource
    private UserMapper userMapper;


    @Autowired
    private  UserService userService;


    @Transactional
    @ApiOperation("test1")
    @RequestMapping("test")
    public ResultData test(User user) throws IOException {
        userService.insert(user);
        return new  ResultData().OK();
    }

    @ApiOperation("test2")
    @RequestMapping("test2")
    public ResultData test02(){
        List<User> users = userMapper.selectList(new EntityWrapper<User>().
                eq("user_id","1"));//参数要求对一个条件集合的包装
        System.out.println(users);
        return new ResultData().OK().setObjs(users);
    }

}
